project( "regression test suite" )

cmake_minimum_required( VERSION 3.22.0 FATAL_ERROR )

#
# Configuration
#
set( SOURCE_DIR "source" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCATCH_CONFIG_MAIN" )

include_directories( SYSTEM ${catch_INCLUDE} ${asio_INCLUDE} )

if( ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=0x0A00 /W4 /wd4068 /wd4702 /wd4996 /wd4265" )
endif ( )

if ( WIN32 )
	set( OPENSSL_DEPS ws2_32.lib advapi32.lib crypt32.lib gdi32.lib user32.lib )
endif ( )

#
# Build
#
add_executable( resources_are_not_overwritten_regression_test_suite ${SOURCE_DIR}/resources_are_not_overwritten.cpp )
target_link_libraries( resources_are_not_overwritten_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( resources_are_not_overwritten_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/resources_are_not_overwritten_regression_test_suite )

add_executable( missing_regex_support_on_gcc_4.8_regression_test_suite ${SOURCE_DIR}/missing_regex_support_on_gcc_4.8.cpp )
target_link_libraries( missing_regex_support_on_gcc_4.8_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( missing_regex_support_on_gcc_4.8_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/missing_regex_support_on_gcc_4.8_regression_test_suite )

add_executable( request_uris_are_not_being_decoded_regression_test_suite ${SOURCE_DIR}/request_uris_are_not_being_decoded.cpp )
target_link_libraries( request_uris_are_not_being_decoded_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( request_uris_are_not_being_decoded_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/request_uris_are_not_being_decoded_regression_test_suite )

add_executable( resource_responding_on_invalid_path_regression_test_suite ${SOURCE_DIR}/resource_responding_on_invalid_path.cpp )
target_link_libraries( resource_responding_on_invalid_path_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( resource_responding_on_invalid_path_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/resource_responding_on_invalid_path_regression_test_suite )

add_executable( segmentation_fault_on_mismatched_path_regression_test_suite ${SOURCE_DIR}/segmentation_fault_on_mismatched_path.cpp )
target_link_libraries( segmentation_fault_on_mismatched_path_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( segmentation_fault_on_mismatched_path_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/segmentation_fault_on_mismatched_path_regression_test_suite )

add_executable( exception_thrown_with_space_in_resource_path_regression_test_suite ${SOURCE_DIR}/exception_thrown_with_space_in_resource_path.cpp )
target_link_libraries( exception_thrown_with_space_in_resource_path_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( exception_thrown_with_space_in_resource_path_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/exception_thrown_with_space_in_resource_path_regression_test_suite )

add_executable( uncaught_exception_when_peer_closes_connection_regression_test_suite ${SOURCE_DIR}/uncaught_exception_when_peer_closes_connection.cpp )
target_link_libraries( uncaught_exception_when_peer_closes_connection_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( uncaught_exception_when_peer_closes_connection_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/uncaught_exception_when_peer_closes_connection_regression_test_suite )

add_executable( error_handler_not_overwritten_regression_test_suite ${SOURCE_DIR}/error_handler_not_overwritten.cpp )
target_link_libraries( error_handler_not_overwritten_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( error_handler_not_overwritten_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/error_handler_not_overwritten_regression_test_suite )

add_executable( large_request_bodies_being_trimmed_regression_test_suite ${SOURCE_DIR}/large_request_bodies_being_trimmed.cpp )
target_link_libraries( large_request_bodies_being_trimmed_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( large_request_bodies_being_trimmed_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/large_request_bodies_being_trimmed_regression_test_suite )

add_executable( fails_to_parse_identical_query_parameters_regression_test_suite ${SOURCE_DIR}/fails_to_parse_identical_query_parameters.cpp )
target_link_libraries( fails_to_parse_identical_query_parameters_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( fails_to_parse_identical_query_parameters_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/fails_to_parse_identical_query_parameters_regression_test_suite )

add_executable( content_length_present_on_empty_response_body_regression_test_suite ${SOURCE_DIR}/content_length_present_on_empty_response_body.cpp )
target_link_libraries( content_length_present_on_empty_response_body_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( content_length_present_on_empty_response_body_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/content_length_present_on_empty_response_body_regression_test_suite )

add_executable( content_type_present_on_empty_response_body_regression_test_suite ${SOURCE_DIR}/content_type_present_on_empty_response_body.cpp )
target_link_libraries( content_type_present_on_empty_response_body_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( content_type_present_on_empty_response_body_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/content_type_present_on_empty_response_body_regression_test_suite )

add_executable( resource_destroyed_with_bound_functors_regression_test_suite ${SOURCE_DIR}/resource_destroyed_with_bound_functors.cpp )
target_link_libraries( resource_destroyed_with_bound_functors_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( resource_destroyed_with_bound_functors_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/resource_destroyed_with_bound_functors_regression_test_suite )

add_executable( fails_to_parse_header_values_containing_colons_regression_test_suite ${SOURCE_DIR}/fails_to_parse_header_values_containing_colons.cpp )
target_link_libraries( fails_to_parse_header_values_containing_colons_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( fails_to_parse_header_values_containing_colons_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/fails_to_parse_header_values_containing_colons_regression_test_suite )

add_executable( string_replace_fails_to_replace_embedded_targets_regression_test_suite ${SOURCE_DIR}/string_replace_fails_to_replace_embedded_targets.cpp )
target_link_libraries( string_replace_fails_to_replace_embedded_targets_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( string_replace_fails_to_replace_embedded_targets_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/string_replace_fails_to_replace_embedded_targets_regression_test_suite )

add_executable( path_parameters_persist_across_keep_alive_requests_regression_test_suite ${SOURCE_DIR}/path_parameters_persist_across_keep_alive_requests.cpp )
target_link_libraries( path_parameters_persist_across_keep_alive_requests_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( path_parameters_persist_across_keep_alive_requests_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/path_parameters_persist_across_keep_alive_requests_regression_test_suite )

add_executable( path_parameters_are_not_visible_within_rules_regression_test_suite ${SOURCE_DIR}/path_parameters_are_not_visible_within_rules.cpp )
target_link_libraries( path_parameters_are_not_visible_within_rules_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( path_parameters_are_not_visible_within_rules_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/path_parameters_are_not_visible_within_rules_regression_test_suite )

add_executable( request_get_parameters_fails_to_return_data_regression_test_suite ${SOURCE_DIR}/request_get_parameters_fails_to_return_data.cpp )
target_link_libraries( request_get_parameters_fails_to_return_data_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( request_get_parameters_fails_to_return_data_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/request_get_parameters_fails_to_return_data_regression_test_suite )

add_executable( uri_fails_to_handle_file_scheme_relative_paths_regression_test_suite ${SOURCE_DIR}/uri_fails_to_handle_file_scheme_relative_paths.cpp )
target_link_libraries( uri_fails_to_handle_file_scheme_relative_paths_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( uri_fails_to_handle_file_scheme_relative_paths_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/uri_fails_to_handle_file_scheme_relative_paths_regression_test_suite )

add_executable( client_fails_to_calculate_body_length_regression_test_suite ${SOURCE_DIR}/client_fails_to_calculate_body_length.cpp )
target_link_libraries( client_fails_to_calculate_body_length_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( client_fails_to_calculate_body_length_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/client_fails_to_calculate_body_length_regression_test_suite )

add_executable( yield_callback_leads_to_service_crash_regression_test_suite ${SOURCE_DIR}/yield_callback_leads_to_service_crash.cpp )
target_link_libraries( yield_callback_leads_to_service_crash_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( yield_callback_leads_to_service_crash_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/yield_callback_leads_to_service_crash_regression_test_suite )

add_executable( service_error_handler_overflow_regression_test_suite ${SOURCE_DIR}/service_error_handler_overflow.cpp )
target_link_libraries( service_error_handler_overflow_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( service_error_handler_overflow_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/service_error_handler_overflow_regression_test_suite )

add_executable( resource_error_handler_overflow_regression_test_suite ${SOURCE_DIR}/resource_error_handler_overflow.cpp )
target_link_libraries( resource_error_handler_overflow_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( resource_error_handler_overflow_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/resource_error_handler_overflow_regression_test_suite )

add_executable( path_parameters_off_by_one_regression_test_suite ${SOURCE_DIR}/path_parameters_off_by_one.cpp )
target_link_libraries( path_parameters_off_by_one_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( path_parameters_off_by_one_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/path_parameters_off_by_one_regression_test_suite )

add_executable( allow_hyphen_in_path_parameter_name_regression_test_suite ${SOURCE_DIR}/allow_hyphen_in_path_parameter_name.cpp )
target_link_libraries( allow_hyphen_in_path_parameter_name_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( allow_hyphen_in_path_parameter_name_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/allow_hyphen_in_path_parameter_name_regression_test_suite )

add_executable( allow_underscore_in_path_parameter_name_regression_test_suite ${SOURCE_DIR}/allow_underscore_in_path_parameter_name.cpp )
target_link_libraries( allow_underscore_in_path_parameter_name_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( allow_underscore_in_path_parameter_name_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/allow_underscore_in_path_parameter_name_regression_test_suite )

add_executable( ipv4_session_origin_destination_malformed_regression_test_suite ${SOURCE_DIR}/ipv4_session_origin_destination_malformed.cpp )
target_link_libraries( ipv4_session_origin_destination_malformed_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( ipv4_session_origin_destination_malformed_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/ipv4_session_origin_destination_malformed_regression_test_suite )

add_executable( locale_creates_incorrect_version_format_regression_test_suite ${SOURCE_DIR}/locale_creates_incorrect_version_format.cpp )
target_link_libraries( locale_creates_incorrect_version_format_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( locale_creates_incorrect_version_format_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/locale_creates_incorrect_version_format_regression_test_suite )

add_executable( request_returning_body_from_prior_requests_regression_test_suite ${SOURCE_DIR}/request_returning_body_from_prior_requests.cpp )
target_link_libraries( request_returning_body_from_prior_requests_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( request_returning_body_from_prior_requests_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/request_returning_body_from_prior_requests_regression_test_suite )

add_executable( ssl_settings_to_handle_windows_path_regression_test_suite ${SOURCE_DIR}/ssl_settings_to_handle_windows_paths.cpp )
target_link_libraries( ssl_settings_to_handle_windows_path_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( ssl_settings_to_handle_windows_path_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/ssl_settings_to_handle_windows_path_regression_test_suite )

add_executable( uri_get_parameter_fails_to_handle_empty_values_regression_test_suite ${SOURCE_DIR}/uri_get_parameter_fails_to_handle_empty_values.cpp )
target_link_libraries( uri_get_parameter_fails_to_handle_empty_values_regression_test_suite ${STATIC_LIBRARY_NAME} ${OPENSSL_DEPS} )
add_test( uri_get_parameter_fails_to_handle_empty_values_regression_test_suite ${EXECUTABLE_OUTPUT_PATH}/uri_get_parameter_fails_to_handle_empty_values_regression_test_suite )
